<template>
  <Loading :loading="loading">
    <div class="content">
      <NavBar>
        <template slot="left"></template>
      </NavBar>
      <div class="detail-info">
        <div class="detail-info-title">{{ infoObj.messageTitle }}</div>
        <div class="detail-info-time">{{ infoObj.sendTime }}</div>
        <div class="detail-info-text" v-html="infoObj.messageContent"></div>
        <div class="detail-info-url">
          <!-- {{ infoObj.productUrl }} -->
          <!-- <a :href="infoObj.productUrl">产品详情</a> -->
        </div>
      </div>
      <div>
        <div class="card">
          <div
            class="pro-list-item flex-row"
            v-for="item in list"
            :key="item.index"
            @click="judgeProductClick(item)"
          >
            <div class="pro-list-item-left">
              <HotsaleIcon v-if="item.isHot === 'Y'" />
              <div>
                <img class="pro-list-item-left-bg" :src="item.logoUrl" />
              </div>
            </div>
            <div class="pro-list-item-right">
              <div class="flex-row">
                <div class="pro-list-item-right-title">
                  {{ item.productName }}
                </div>
                <div
                  :class="
                    item.isOnline === 'Y'
                      ? 'pro-list-item-right-title-text'
                      : 'active'
                  "
                >
                  {{ item.isOnline === 'Y' ? '线上' : '线下' }}
                </div>
              </div>
              <div class="pro-list-item-right-desc flex-row">
                <div>{{ item.productAbbrDescription }}</div>
              </div>
              <div class="pro-list-item-right-protype">
                <div
                  v-for="item in getLabelList(item.customLabel)"
                  :key="item.index"
                >
                  {{ item }}
                </div>
              </div>
              <div class="pro-list-item-right-money">
                {{ item.startPrice }}
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </Loading>
</template>
<script>
import NavBar from '@/components/h5header'
import API from '@/services/h5/msg'
import productAPI from '@/services/h5/product'
import judgeProClick from '@/mixin/judgeProClick'
import Loading from '@/components/data-loading'

// import HotsaleIcon from '@/components/hotsale'
export default {
  components: { NavBar, Loading },
  mixins: [judgeProClick],
  data() {
    return {
      infoObj: {},
      list: [],
      loading: false
    }
  },
  created() {
    this.getData()
    this.getproduct()
  },
  methods: {
    handleClose() {},
    handleShare() {},

    async getData() {
      this.infoObj = this.$route.query
      if (this.$route.query.readFlag === 'N') {
        this.setReadFlag()
      }
    },
    async setReadFlag() {
      // let id = this.$route.query.productId
      // let id = this.$route.query.id
      let id = this.$route.query.id
      const res = await API.readById(id)
      if (res.data && res.data.code === 1000) {
        console.log('')
      }
    },
    getproduct() {
      this.loading = true
      let params = {
        productId: this.$route.query.productId
      }
      productAPI.getprodList(params).then(res => {
        if (res.data && res.data.code === 1000) {
          this.list = res.data.data.list
        }
        this.loading = false
      })
    },
    getLabelList(value) {
      if (value.indexOf(',') > -1) {
        return value.split(',')
      } else {
        return [value]
      }
    }
  }
}
</script>
<style scoped lang="less">
.content {
  background: #fafafa;
  height: calc(100vh);
  .c-wc8ybt {
    width: 18px;
    height: 18px;
    margin-left: 5px;
  }
  .header-title {
    width: 232px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .detail-info {
    position: relative;
    // padding-bottom: 50px;
    &-title {
      font-size: 17px;
      font-weight: bold;
      color: #333;
      padding: 0 15px;
      margin-top: 20px;
    }
    &-text {
      font-size: 17px;
      color: #333;
      padding: 0 15px;
      margin-top: 10px;
      padding-top: 10px;
      border-top: 0.5px solid #e5e5e5;
    }
    &-url {
      width: 375px;
      box-sizing: border-box;
      padding: 0 15px;
      font-size: 18px;
      word-wrap: break-word;
      a {
        // color: @c-color-primary;
        text-decoration: none;
        color: blue;
        border-bottom: 1px solid blue;
      }
    }
    &-time {
      padding: 0 15px;
      margin-top: 10px;
      font-size: 13px;
      color: #999;
    }
    &-img {
      width: 375px;
    }
    &-footer {
      position: fixed;
      bottom: 0;
      height: 50px;
      width: 375px;
      box-shadow: rgba(0, 0, 0, 0.04) 0 -0.5px 2px 0;
      background: #fff;
      display: flex;
      flex-direction: column;
      justify-content: center;
      &-list-item {
        margin-left: 10px;
        padding: 5px 15px;
        border-radius: 16.5px;
        border: 0.5px solid #ccc;
        font-size: 11px;
        color: #999;
        img {
          width: 14px;
          height: 14px;
        }
      }
    }
  }
  .card {
    background-color: #fff;
    border-radius: 10px;
    width: 345px;
    margin: 0 auto;
    box-shadow: rgba(0, 0, 0, 0.07) 0 0 8px 0;
    margin-top: 15px;
    .pro-list-item {
      margin: 0 15px;
      padding: 15px 0;
    }
    .pro-list-item-left {
      position: relative;
      background: #fff9ee;
      box-shadow: rgba(0, 0, 0, 0.05) 0 0 8px 0;
      border-radius: 4px;
      width: 86px;
      height: 86px;
      box-sizing: border-box;
      &-bg {
        position: absolute;
        bottom: 0;
        right: 0;
        width: 86px;
        height: 86px;
      }
      &-insurance {
        position: absolute;
        bottom: 0;
        width: 86px;
        height: 20px;
        line-height: 20px;
        // margin: 50px;
        background: #f68657;
        border-radius: 50% / 100% 100% 0 0;
        color: #fff;
        font-size: 10px;
        font-weight: bold;
        text-align: center;
      }
    }
    .pro-list-item-right {
      flex: 1;
      margin-left: 15px;
      &-title {
        font-size: 16px;
        font-weight: bold;
        color: #333;
        flex: 1;
      }
      &-title-text {
        display: flex;
        justify-content: center;
        align-items: center;
        width: 28px;
        height: 16px;
        // line-height: 16px;
        // text-align: center;
        margin-left: 8px;
        border-radius: 4px;
        border: 0.5px solid @c-color-primary;
        background: #fde6dd;
        font-size: 12px;
        color: @c-color-primary;
        margin-top: 2px;
      }
      .active {
        display: flex;
        justify-content: center;
        align-items: center;
        width: 28px;
        height: 16px;
        // line-height: 16px;
        // text-align: center;
        margin-left: 8px;
        border-radius: 4px;
        font-size: 12px;
        color: #1a73e8;
        background-color: #94d8f6;
        border: 0.5px solid #1a73e8;
        margin-top: 2px;
      }
      &-desc {
        font-size: 13px;
        color: #999;
        margin-top: 5px;
      }
      &-protype {
        font-size: 12px;
        color: #bd893a;
        // margin-left: 5px;
        margin-top: 5px;
        div {
          display: inline-block;
          margin-right: 5px;
        }
      }
      &-money {
        font-size: 17px;
        font-weight: bold;
        color: #ec4001;
        margin-top: 2px;
      }
    }
  }
}
</style>
